bool isPalindrome(int x)
{
    if (x < 0) return false;

    int a[100];
    int i = 0;

    do
    {
        a[i] = x % 10;
        x /= 10;
        i++;
    } while (x);

    for (int k = 0; k <= i / 2; k++)
    {
        if (a[k] != a[i - k - 1])
            return false;
    }
    return true;
}